#ifndef CASSETMANAGER_H_
#define CASSETMANAGER_H_


////////////////////////////////
// MACROS!
////////////////////////////////
#define RELEASE( param ) if( param != NULL ){ delete param; param = NULL; }
#define RELEASE_DRX( param ) if( param != NULL ){ param->Release( ); param = NULL; }


//////////////////////////////////////
// Headers and Libraries
//////////////////////////////////////
#include <d3d9.h>
#include <d3dx9.h>
#pragma comment ( lib, "d3d9.lib")
#pragma comment( lib, "d3dx9.lib")

#include <vector>
#include "../AnimConfig.h"

//REMOVE THIS
struct TROGTEX
{
	D3DXVECTOR3 Position;
	D3DXVECTOR3 Normal;
	D3DXVECTOR2 UV;
};
////

struct TANIMVERTEX
{
	D3DXVECTOR3 position;
	D3DXVECTOR3 normal;
	D3DXVECTOR2 uv;
	D3DXVECTOR3 weights;
	D3DXVECTOR3 weightIndices;
};

struct TMesh
{
	// Vert info
	IDirect3DVertexBuffer9* pVertBuffer;

	// Index info
	IDirect3DIndexBuffer9* pIndexBuffer;

	// Num vertices
	unsigned int nNumVerts;
	
	// Number of primitives
	unsigned int nNumTris;
};

struct TAnimMesh : public TMesh
{
	D3DXMATRIX BindPose[MAX_JOINTS];
};

class CAssetManager
{
private:
	std::vector<TMesh*> m_vMeshes;
	std::vector<ID3DXEffect*> m_vShaders;

	IDirect3DDevice9* m_pDev;

	void ShutdownMesh( TMesh* pMesh );
public:
	CAssetManager( void );
	~CAssetManager( void );

	void Initialize( IDirect3DDevice9* pDev );
	void LoadShaders( const char* szFileName );
	unsigned int LoadMesh( const char* szFileName );
	unsigned int LoadAnimatedMesh( const char* szFileName );

	TMesh* GetMesh( unsigned int nID );
	ID3DXEffect* GetShader( unsigned int nID );

	void Shutdown( void );

	//REMOVE THIS //
	//
	IDirect3DVertexDeclaration9* trogdorDecl;
	IDirect3DVertexBuffer9* trogdorMeshVerts;
	IDirect3DIndexBuffer9* trogdorMeshIndex;
	IDirect3DTexture9* trogdorTexture;
	int trogVerts;
	int trogTris;
	unsigned int LoadTROGDOR( const char* szFileName );
	//
	// END REMOVAL //
};

#endif